package com.dzx.currentency.publish;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;

/**
 * @author DuanZhaoXu
 * @ClassName:
 * @Description:
 * @date 2018年11月19日 09:14:44
 */
@Slf4j
public class UnSafePublish {

    private String[] states = {"a", "b", "c"};

    /**
     * 无法确保 其他的线程会通过调用此方法，来修改私有的成员变量
     *
     * @return
     */
    public String[] getStates() {
        return states;

    }

    public static void main(String[] args) {
        UnSafePublish unSafePublish = new UnSafePublish();
        log.info("{}", Arrays.toString(unSafePublish.getStates()));

        unSafePublish.getStates()[0] = "d";
        log.info("{}", Arrays.toString(unSafePublish.getStates()));
    }
}
